package com.lagou.edu.controller;

import com.lagou.edu.service.IDemoService;
import org.framework.mvc.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName: DemoController
 * @Auther: Jerry
 * @Date: 2020/7/13 15:01
 * @Desctiption: TODO
 * @Version: 1.0
 */
@MyController
@MyRequestMapping("/demo")
public class DemoController {

    @MyAutoWired
    private IDemoService demoService;

    /**
     * 注解用于类或方法上，表明哪个用户拥有访问该handler的哪个权限
     * 访问handler时，用户名直接以参数名username紧跟在请求后面，如：http://localhost:8080/demo/test?username=zhangsan
     * 有权限则放行，没有权限则在页面输出无权访问。
     */
    @Security({"zhangsan"})
    @MyRequestMapping("/test01")
    public String test01(HttpServletRequest request, HttpServletResponse response, String username){
        return this.demoService.getName(username);
    }

    @Security({"lisi"})
    @MyRequestMapping("/test02")
    public String test02(HttpServletRequest request, HttpServletResponse response, String username){
        return this.demoService.getName(username);
    }

    @Security({"wangwu"})
    @MyRequestMapping("/test03")
    public String test03(HttpServletRequest request, HttpServletResponse response, String username){
        return this.demoService.getName(username);
    }

    @Security({"wangmazi"})
    @MyRequestMapping("/test04")
    public String test04(HttpServletRequest request, HttpServletResponse response, String username){
        return this.demoService.getName(username);
    }
}
